import React, { Component, createRef } from 'react'

// 非受控组件
export default class UnControlled extends Component {

  state = {
    value: ''
  }

  constructor() {
    super()
    this.inpt = createRef()
  }

  handleInput(e) {
    this.setState({
      value: e.target.value
    })
  }

  handleGetValueClick() {
    console.log(this.inpt.current.value)
  }

  render() {
    return (
      <div>
        {/* <input type="text" onInput={this.handleInput.bind(this)}/> */}
        <input ref={this.inpt} type="text"/>
        {this.state.value}

        <button onClick={this.handleGetValueClick.bind(this)}>get value</button>
      </div>
    )
  }
}
